package top.forgirl.common.result;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

@Getter
@ToString
@ApiModel("统一的返回结果集")
public class Result<T> {
    @ApiModelProperty(value = "响应信息", example = "SUCCESS")
    private String msg;
    @ApiModelProperty(value = "响应码", example = "2000")
    private Integer code;
    @ApiModelProperty(value = "响应数据")
    private T data;

    public Result(ResultType resultType, T data) {
        this.code = resultType.getCode();
        this.msg = resultType.getMsg();
        this.data = data;
    }

    public Result(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Result(T data) {
        this(ResultType.SUCCESS, data);
    }

}
